package com.ratta.supernote.plugin.sticker.lib.view.editText.editor;

import androidx.annotation.Nullable;

/**
 * 光标区域信息
 */
public class CursorRect {
    // 文本框内的相对X轴坐标
    public float cursorX;
    // 文本框内的相对坐标，top是光标顶部位置
    public float top;
    // 文本框内的相对坐标，bottom是光标底部位置
    public float bottom;

    public CursorRect(float cursorX, float top, float bottom) {
        this.cursorX = cursorX;
        this.top = top;
        this.bottom = bottom;
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if(!(obj instanceof CursorRect)) {
            return false;
        }
        CursorRect cursorRect = (CursorRect) obj;

        return Math.abs(cursorX - cursorRect.cursorX) <=0.01f
                && Math.abs(top - cursorRect.top) <=0.01f
                && Math.abs(bottom - cursorRect.bottom) <=0.01f;
    }

    @Override
    public String toString() {
        return "CursorRect{" +
                "cursorX=" + cursorX +
                ", top=" + top +
                ", bottom=" + bottom +
                '}';
    }
}
